package com.glsc.ngateway.common.base.repo.mysql.opmanagemain.performance;

import com.glsc.ngateway.common.base.domain.mysql.opmanagemain.ledger.LedgerAuth;
import com.glsc.ngateway.common.base.domain.mysql.opmanagemain.performance.DayPerformanceItem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;


@Repository
public interface DayPerformanceItemRepository extends JpaRepository<DayPerformanceItem, Integer>, JpaSpecificationExecutor<DayPerformanceItem> {


    @Query(value = "select sum( d.man_hour ) from t_day_performance_item d where  " +
            "d.user_oa_account = :userOaAccount  " +
            "and d.ledger_type = :ledgerType  " +
            "and d.post_name = :postName  " +
            "and d.create_time >= :startTime  " +
            "and d.create_time <= :endTime  ", nativeQuery = true)
    Integer findUserSumManHour(@Param("userOaAccount") String userOaAccount, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("ledgerType") String ledgerType, @Param("postName") String postName);

}
